using System;
using UnityEngine;
using Unity.VisualScripting;
using ResourceUpdateStartEventArgs = UnityGameFramework.Runtime.ResourceUpdateStartEventArgs;

namespace LS.UGFUnits
{
    [UnitShortTitle("Resource Update")]
    [UnitSurtitle("Start")]
    public sealed class ResourceUpdateStart : FrameworkEventUnit<ResourceUpdateStartEventArgs>
    {
        protected override int EventId => ResourceUpdateStartEventArgs.EventId;
        protected override string HookName => UGFHookNames.ResourceUpdateStart;

        [DoNotSerialize]
        [PortLabelHidden]
        public ValueOutput Name
        {
            get;
            private set;
        }

        [DoNotSerialize]
        [PortLabelHidden]
        public ValueOutput DownloadPath
        {
            get;
            private set;
        }

        [DoNotSerialize]
        [PortLabelHidden]
        public ValueOutput DownloadUri
        {
            get;
            private set;
        }

        [DoNotSerialize]
        [PortLabelHidden]
        public ValueOutput CurrentLength
        {
            get;
            private set;
        }

        [DoNotSerialize]
        [PortLabelHidden]
        public ValueOutput CompressedLength
        {
            get;
            private set;
        }

        [DoNotSerialize]
        [PortLabelHidden]
        public ValueOutput RetryCount
        {
            get;
            private set;
        }
        
        protected override void Definition()
        {
            base.Definition();
            Name = ValueOutput<string>(nameof(Name));
            DownloadPath = ValueOutput<string>(nameof(DownloadPath));
            DownloadUri = ValueOutput<string>(nameof(DownloadUri));
            CurrentLength = ValueOutput<int>(nameof(CurrentLength));
            CompressedLength = ValueOutput<int>(nameof(CompressedLength));
            RetryCount = ValueOutput<int>(nameof(RetryCount));
        }

        protected override void AssignArguments(Flow flow, ResourceUpdateStartEventArgs args)
        {
            base.AssignArguments(flow, args);
            flow.SetValue(Name, args.Name);
            flow.SetValue(DownloadPath, args.DownloadPath);
            flow.SetValue(DownloadUri, args.DownloadUri);
            flow.SetValue(CurrentLength, args.CurrentLength);
            flow.SetValue(CompressedLength, args.CompressedLength);
            flow.SetValue(RetryCount, args.RetryCount);
        }
    }
}